package com.zhentao.controller;

import com.zhentao.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class MongoController {
    @Autowired
    private MongoTemplate mongoTemplate;

    @GetMapping("/findAll")
    public String findAll(){
      List<Student> students= mongoTemplate.findAll(Student.class);
        System.out.println(students);
        return students.toString();
    }
}